package com.bjbn.dto;

import lombok.Data;
import java.util.Date;

/**
 * 数据清理结果DTO
 */
@Data
public class DataCleanResult {
    
    /**
     * 清理是否成功
     */
    private boolean success;
    
    /**
     * 清理消息
     */
    private String message;
    
    /**
     * 清理开始时间
     */
    private Date startTime;
    
    /**
     * 清理结束时间
     */
    private Date endTime;
    
    /**
     * 清理耗时（毫秒）
     */
    private long duration;
    
    /**
     * 清理的数据总数
     */
    private long deletedCount;
    
    /**
     * 清理前的数据总数
     */
    private long totalCount;
    
    /**
     * 清理的批次数
     */
    private int batchCount;
    
    /**
     * 表名
     */
    private String tableName;
    
    public static DataCleanResult success(String tableName, long deletedCount, long totalCount, 
                                        int batchCount, Date startTime, Date endTime) {
        DataCleanResult result = new DataCleanResult();
        result.setSuccess(true);
        result.setMessage("数据清理成功");
        result.setTableName(tableName);
        result.setDeletedCount(deletedCount);
        result.setTotalCount(totalCount);
        result.setBatchCount(batchCount);
        result.setStartTime(startTime);
        result.setEndTime(endTime);
        result.setDuration(endTime.getTime() - startTime.getTime());
        return result;
    }
    
    public static DataCleanResult failure(String tableName, String errorMessage, Date startTime) {
        DataCleanResult result = new DataCleanResult();
        result.setSuccess(false);
        result.setMessage("数据清理失败: " + errorMessage);
        result.setTableName(tableName);
        result.setStartTime(startTime);
        result.setEndTime(new Date());
        result.setDuration(result.getEndTime().getTime() - startTime.getTime());
        return result;
    }
}
